<%@page import="java.sql.SQLException"%>
<%@page import="java.rmi.RemoteException"%>
<%@page import="exception.LoggedInException"%>
<%@page import="org.w3c.dom.Document"%>
<%@page import="exception.NotRegisteredException"%>
<%@page import="java.rmi.Naming"%>
<%@page import="server.ForumHandlerInt"%>
(
<%@ include file="serverConnection.jsp" %>
<%  
   try
	{
		String premission = "";
		premission = forum.login(request.getParameter( "userName" ),request.getParameter( "password" ));
		session.setAttribute("permission",premission);
		//if we have arrived here from loggin page we will set user name and password
		//in the session
		if (request.getParameter("userName")!=null )
			session.setAttribute("userName",request.getParameter("userName"));

		if (request.getParameter("password")!=null)
		session.setAttribute("password",request.getParameter("password"));
   %>
   		"ok"
   
   <% 
	}
   catch(NotRegisteredException e){
	%>
	"wrong user name or password"
	<% 
   }
   catch(LoggedInException t){
	   %>
	   "you are logged in"
	   <% 
   }
   catch(SQLException s){
	   
	   
	   response.sendError(response.SC_INTERNAL_SERVER_ERROR,
		"SQL server is down");
	
		response.flushBuffer();
		return;
	   
	   
   }
   catch(RemoteException u){
	   
	   response.sendError(response.SC_INTERNAL_SERVER_ERROR,
		"forum server is down");
	
		response.flushBuffer();
		return;
   }


%>
)
